import { createRouter, createWebHashHistory } from "vue-router";
// 引入布局组件
import layout from "@/views/layout";

const routes = [
  {
    path: "",
    redirect: "/login",
    hidden: true,
    meta: {
      name: "主页"
    }
  },
  {
    path: "/login",
    name: "Login",
    hidden: true,
    component: () => import("@/views/login/index.vue"),
    meta: {
      name: "登录"
    }
  },
  {
    path: "/console",
    name: "Console",
    redirect: "index",
    component: layout,
    meta: {
      name: "控制台",
      icon: "house"
    },
    children: [
      {
        path: "/index",
        name: "Index",
        component: () => import("@/views/console/index.vue"),
        meta: {
          name: "首页"
        }
      }
    ]
  },
  {
    path: "/info",
    name: "Info",
    component: layout,
    meta: {
      name: "信息管理",
      icon: "document"
    },
    children: [
      {
        path: "/infoIndex",
        name: "InfoIndex",
        component: () => import("@/views/info/index.vue"),
        meta: {
          name: "信息列表"
        }
      },
      {
        path: "/infoCategory",
        name: "InfoCategory",
        component: () => import("@/views/info/category.vue"),
        meta: {
          name: "信息分类"
        }
      }
    ]
  },
  {
    path: "/user",
    name: "User",
    component: layout,
    meta: {
      name: "用户管理",
      icon: "user"
    },
    children: [
      {
        path: "/userIndex",
        name: "UserIndex",
        component: () => import("@/views/user/index.vue"),
        meta: {
          name: "用户列表"
        }
      },
    ]
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
